package com.ifind.test.my;

import com.ifind.async.callback.ICallback;
import com.ifind.async.callback.IWorker;
import com.ifind.async.worker.WorkResult;
import com.ifind.async.wrapper.WorkerWrapper;

import java.util.Map;

/**
 * @author: Carlos
 * @create: 2020/10/29 15:03
 */
public class DeWorker02 implements IWorker<String, String>, ICallback<String, String> {
    @Override
    public String action(String object, Map<String, WorkerWrapper> allWorkers) {
        System.out.println("------------------");
        WorkResult workResult = allWorkers.get("01").getWorkResult();
        String result = (String) workResult.getResult();
        System.out.println("DeWorker02的参数" + result);
        System.out.println("开始执行DeWorker02");
        String s = result + "ws";
        System.out.println("结束执行DeWorker02");
        return s;
    }

    @Override
    public void result(boolean success, String param, WorkResult<String> workResult) {
        if (success) {
            System.out.println("result - DeWorker01执行结果: " + workResult.getResult());
        }
    }
}
